//
//  ZQEmotionKeyboardView.swift
//  ZQWeibo
//
//  Created by summer的Dad on 16/11/23.
//  Copyright © 2016年 summer的Dad. All rights reserved.
//

import UIKit
let enmotionKeyBoardHeight : CGFloat = 220

let enmotionToolBarHeight : CGFloat = 37

private let enmotionID = "enmtionID"
class ZQEmotionKeyboardView: UIView {
   

    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
    //    self.backgroundColor = UIColor.blue
        
        
         setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    //设置UI界面
    func setupUI() {
    
        addSubview(emotionTool)
 
        addSubview(conllectionView)
//        addSubview(pagecongtroller)
//        addSubview(recentLable)
       //约束
        emotionTool.snp.makeConstraints { (make) in
            make.leading.trailing.bottom.equalTo(self)
            
            make.height.equalTo(enmotionToolBarHeight)
        }
        conllectionView.snp.makeConstraints { (make) in
            
            make.leading.trailing.top.equalTo(self)
            make.bottom.equalTo(emotionTool.snp.top)
        }
        
        emotionTool.enmotionBtnTag = {type in

            
            
            
        }
        
    }
    //设置CV
    private lazy var conllectionView : UICollectionView = {
        
        let layout = UICollectionViewFlowLayout()
        
        layout.scrollDirection = .horizontal
        layout.minimumInteritemSpacing = 0
        layout.minimumLineSpacing = 0
        
        layout.itemSize = CGSize(width: ScreenWidth, height: enmotionKeyBoardHeight - enmotionToolBarHeight)
        
        let vc = UICollectionView(frame: CGRect.zero ,collectionViewLayout:layout)
            vc.isPagingEnabled = true
            vc.dataSource = self
            
        vc.register(UICollectionViewCell.self, forCellWithReuseIdentifier:enmotionID)
        
        return vc
    }()
    //懒加载ToolBar
    private lazy var emotionTool : ZQEmotionToolBar  = ZQEmotionToolBar()
    //加载 pagecollto
    private lazy var pagecongtroller : UIPageControl = UIPageControl()
        
    //
    private lazy var recentLable : UILabel = UILabel(title: "最近的", fontSize: 10, textColor: UIColor.orange)
    
    
    
    
}

   extension ZQEmotionKeyboardView : UICollectionViewDataSource{
    
    
    
    //返回组
    func numberOfSections(in collectionView: UICollectionView) -> Int {
        return 4
    }
    //返回列
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
        return 3
    }
    //返回单元格
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: enmotionID, for: indexPath)
        cell.backgroundColor = randomColor()
        
        return cell
        
    }
    
    
    
    
}















